package com.cti.ftpservice.ws.impl;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "http://impl.ws.ftpservice.cti.com/", propOrder = {
		"module", "errorCode", "args" })
public class WSFault {
	private List<String> args;
	private String errorCode;
	private ErrorModule module;

	public WSFault() {
		super();
		this.module = new ErrorModule();
		this.errorCode = "";
		this.args = new ArrayList<String>();
	}

	public WSFault(ErrorModule module, String errorCode) {
		super();
		this.module = module;
		this.errorCode = errorCode;
		this.args = new ArrayList<String>();
	}

	public WSFault(ErrorModule module, String errorCode, List<String> args) {
		super();
		this.module = module;
		this.errorCode = errorCode;
		this.args = args;
	}

	public List<String> getArgs() {
		return args;
	}

	public String getErrorCode() {
		return errorCode;
	}

	public ErrorModule getModule() {
		return module;
	}

	public void setArgs(List<String> args) {
		this.args = args;
	}

	public void setErrorCode(String errorCode) {
		this.errorCode = errorCode;
	}

	public void setModule(ErrorModule module) {
		this.module = module;
	}

	@Override
	public String toString() {
		StringBuffer buffer = new StringBuffer();
		buffer.append("错误模块：" + module.getModuleName());
		buffer.append(System.getProperty("line.separator"));
		buffer.append("错误代码：" + errorCode);
		buffer.append(System.getProperty("line.separator"));
		buffer.append("参数信息：[");
		if (args != null && args.size() > 0) {
			for (int i = 0; i < args.size(); i++) {
				String arg = (i == args.size() - 1) ? args.get(i) : args.get(i)
						+ ",";
				buffer.append(arg);
			}
		}
		buffer.append("]");
		return buffer.toString();
	}
}
